import 'package:flutter/material.dart';
import 'package:flutter_mode/utils.dart';
import 'package:flutter_mode/zjw/data_transfer/InheritedWidget.dart';
import 'package:flutter_mode/zjw/data_transfer/Redux.dart';
import 'package:flutter_mode/zjw/data_transfer/ScopedModel.dart';
import 'package:flutter_mode/zjw/data_transfer/TodosScreen.dart';

class DataTransferWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    var items = {
      '构造函数传递数据': () => pushMaterial(context, TodosScreen()),
      'InheritedWidget传递数据': () =>
          pushMaterial(context, InheritedWidgetContainer()),
      'ScopedModel传递数据': () => pushMaterial(context, ScopedModelWidget()),
      'Redux传递数据': () => pushMaterial(context, ReduxWidget()),
    };
    Widget list = ListView.separated(
        itemBuilder: (context, index) {
          var item = items.entries.elementAt(index);
          return ListTile(title: Text(item.key), onTap: item.value);
        },
        separatorBuilder: (context, index) => Divider(height: 1),
        itemCount: items.length);
    return new Scaffold(
      appBar: new AppBar(
        leading: BackButton(),
        title: new Text('数据传递'),
      ),
      body: list,
    );
  }
}
